{% extends 'base.html' %}
{% load static %}

{% block title %}{{ profile_user.username }}的资料 - AI故事生成系统{% endblock %}

{% block content %}
<div class="container mt-4">
    <div class="row">
        <div class="col-md-4">
            <div class="card">
                <div class="card-body text-center">
                    {% if profile and profile.avatar %}
                        <img src="{{ profile.avatar.url }}" alt="{{ profile_user.username }}" class="rounded-circle mb-3" style="width: 150px; height: 150px; object-fit: cover;">
                    {% else %}
                        <img src="{% static 'admin/img/tx.png' %}" alt="{{ profile_user.username }}" class="rounded-circle mb-3" style="width: 150px; height: 150px; object-fit: cover;">
                    {% endif %}
                    <h3>{{ profile_user.username }}</h3>
                    <p class="text-muted">{{ profile.bio|default:"这个人很懒，什么都没写" }}</p>
                    <div class="d-flex justify-content-center gap-2">
                        <span class="badge bg-primary">{{ profile_user.story_set.count }} 篇故事</span>
                        <span class="badge bg-success">{{ profile_user.followers.count }} 关注者</span>
                        <span class="badge bg-info">{{ profile_user.following.count }} 关注中</span>
                    </div>
                    {% if user.is_authenticated and user != profile_user %}
                        <form action="{% url 'user:follow' profile_user.username %}" method="post" class="mt-3">
                            {% csrf_token %}
                            {% if user in profile_user.followers.all %}
                                <button type="submit" class="btn btn-outline-danger">取消关注</button>
                            {% else %}
                                <button type="submit" class="btn btn-outline-primary">关注</button>
                            {% endif %}
                        </form>
                    {% endif %}
                </div>
            </div>
        </div>
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">
                    <h4 class="mb-0">故事列表</h4>
                </div>
                <div class="card-body">
                    {% if stories %}
                        <div class="list-group">
                            {% for story in stories %}
                                <a href="{% url 'story:detail' story.pk %}" class="list-group-item list-group-item-action">
                                    <div class="d-flex w-100 justify-content-between">
                                        <h5 class="mb-1">{{ story.title }}</h5>
                                        <small class="text-muted">{{ story.created_at|date:"Y-m-d" }}</small>
                                    </div>
                                    <p class="mb-1">{{ story.content|striptags|truncatechars:100 }}</p>
                                    <small class="text-muted">
                                        <i class="fas fa-eye"></i> {{ story.views }}
                                        <i class="fas fa-heart ms-2"></i> {{ story.likes }}
                                    </small>
                                </a>
                            {% endfor %}
                        </div>
                    {% else %}
                        <p class="text-muted text-center">还没有发布任何故事</p>
                    {% endif %}
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %} 